home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
GotoDialog.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-27
|
2KB
|
88 lines
#ifdef __GNUG__
#pragma implementation
#endif
#include "GotoDialog.h"
#include "Class.h"
#include "Dialog.h"
#include "Window.h"
#include "Fields.h"
#include "TextView.h"
#include "BorderItems.h"
#include "Buttons.h"
#include "Document.h"
#include "WindowSystem.h"
#include "ObjectTable.h"
#include "Expander.h"
#include "Math.h"
static GotoDialog *gotoDialog;
//---- entry Point -------------------------------------------------------------
void GotoLine(TextView *tv)
{
if (gotoDialog == 0)
gotoDialog= new GotoDialog;
gotoDialog->ShowGotoDialog(tv);
}
ONEXIT(GotoDialog)
{
SafeDelete(gotoDialog);
}
//---- GotoDialog --------------------------------------------------------------
NewMetaImpl(GotoDialog, Dialog, (TP(view), TP(line), TP(gotoDialog)));
GotoDialog::GotoDialog() : Dialog("Goto")
{
line= 0;
}
void GotoDialog::ShowGotoDialog(TextView *v)
{
if (v) {
view= v;
if (ShowOnWindow(v->GetWindow()) == cIdYes) {
int at= line->GetValue();
LineMark *lm= view->MarkAtLine(at-1);
view->SetSelection(lm->Pos(), lm->End(), TRUE);
view->RevealSelection();
GraphicDelay(500);
view->SetSelection(lm->Pos(), lm->Pos(), TRUE);
}
}
}
VObject *GotoDialog::DoMakeContent()
{
return
new Matte(10,
new VExpander(20,
new HBox(10, (VObjAlign)(eVObjVBase|eVObjHExpand),
new TextItem("Go to line:"),
line= new IntField(cIdNone),
0
),
new HBox(20, (VObjAlign)(eVObjVBase|eVObjHEqual|eVObjHExpand),
new ActionButton(cIdYes, "Go to", TRUE),
new ActionButton(cIdCancel, "Cancel"),
0
),
0
)
);
}
void GotoDialog::DoSetDefaults()
{
int f, t;
view->GetSelection(&f, &t);
line->SetValue(view->CharToLine(f)+1);
line->SetRange(1, Math::Max(1, view->NumberOfLines()));
}